home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ShimEnetStub.c
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1998-2000 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: xxx put dri here xxx
-
- Other Contact: xxx put other contact here xxx
-
- Technology: xxx put technology here xxx
-
- */
-
- #include <Errors.h>
- #include <LowMem.h>
- #include <TextUtils.h>
-
- #include "USBEnet.h"
- #include "USBEnetVersion.h"
- #include "ShimEnetStub.h"
-
- /***********************************************************************************/
- // Function: InstallShimDrvr(CFragConnectionID ConnID)
- // Description: Handles the interface with the shim install
- //
- // Input: CFrag Connection ID (mine)
- // Output: Results
- /***********************************************************************************/
-
- OSErr InstallShimDrvr(CFragConnectionID ConnID)
- {
- OSErr err;
- ShimRefNum Tref; // need to do this cause occasionally the globals get lost
- // passing the address to the Shim (it switches zones)
- EnetShimInterface IntBlk;
-
- TraceMessage(0, kDrvName"- Entering InstallShimDrvr");
-
- err = LoadShim();
- if (err == noErr)
- {
- IntBlk.DRVName = (unsigned char *)&gGlobals->rname;
- IntBlk.RefCon = 0;
- IntBlk.ConnID = ConnID;
- IntBlk.theID = (UInt32)&gGlobals->theID;
- err = (*gGlobals->ShimInstall) (IntBlk, &Tref);
- gGlobals->ShimRef = Tref;
- }
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: RemoveShimDrvr(Boolean forceFlag)
- // Description: Handles the interface with the shim remove
- //
- // Input: Orderly or forced
- // Output: Results
- /***********************************************************************************/
-
- OSErr RemoveShimDrvr(Boolean forceFlag)
- {
- OSErr err;
-
- TraceMessage(0, kDrvName"- Entering RemoveShimDrvr");
-
- if (gGlobals->ShimRef != kInvalidRef)
- {
- err = (*gGlobals->ShimRemove) (gGlobals->ShimRef, forceFlag);
- if (err == noErr)
- UnLoadShim();
-
- if (err > 0) // if it's pending the shim handles from here
- err = noErr; // but we can't unload yet
-
- } else {
- err = -1;
- }
-
- gGlobals->ShimRef = kInvalidRef;
- return err;
- }
-
- /***********************************************************************************/
- // Function: LoadShim
- // Description: Loads the shim and sets up the various addresses
- //
- // Input: Nothing
- // Output: Results
- /***********************************************************************************/
-
- OSErr LoadShim(void)
- {
- OSErr err = noErr; // Let's assume success
- Ptr FragAddr;
- CFragConnectionID ConnID;
- Str255 errMsg;
- CFragSymbolClass cClass;
-
- err = GetSharedLibrary("\pEnetShimLib", kPowerPCCFragArch, kLoadCFrag, &ConnID, &FragAddr, errMsg);
- if (err == noErr)
- {
- gGlobals->ConnID = ConnID;
- err = FindSymbol(ConnID, Shim_Install, (Ptr *)&gGlobals->ShimInstall, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
-
- if (err == noErr)
- {
- err = FindSymbol(ConnID, Shim_Remove, (Ptr *)&gGlobals->ShimRemove, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
- }
-
- if (err == noErr)
- {
- err = FindSymbol(ConnID, Shim_Async, (Ptr *)&gGlobals->ShimAsync, &cClass);
- if ((err != noErr) || (cClass != kTVectorCFragSymbol))
- {
- err = -1;
- }
- }
- }
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: UnLoadShim
- // Description: UnLoads the shim, actually closes the connection
- //
- // Input: Nothing
- // Output: Results
- /***********************************************************************************/
-
- OSErr UnLoadShim(void)
- {
- OSErr err = noErr; // Let's assume success
-
- err = CloseConnection(&gGlobals->ConnID);
-
- return err;
-
- }